package tmsdkobf; import android.content.Context; import android.net.DhcpInfo; import android.net.wifi.ScanResult; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; import com.miui.guardprovider.engine.mi.antivirus.NetworkApiHelper; import com.qq.taf.jce.JceStruct; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.util.ArrayList; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Matcher; import java.util.regex.Pattern; import tmsdk.bg.creator.BaseManagerB; import tmsdk.bg.module.network.ITrafficCorrectionListener; import tmsdk.bg.module.wifidetect.IWifiBatchDetectListener; import tmsdk.bg.module.wifidetect.IWifiDetectListener; import tmsdk.bg.module.wifidetect.WifiDetectManager; import tmsdkobf.mg; public class jf extends BaseManagerB { /* renamed from: b reason: collision with root package name */ private Context f1371b; private WifiManager c; private Handler d; volatile AtomicBoolean e = new AtomicBoolean(false); /* access modifiers changed from: package-private */ public class a extends Handler { a(jf jfVar, Looper looper) { super(looper); } public void handleMessage(Message message) { IWifiBatchDetectListener iWifiBatchDetectListener; int i = message.what; if (i == 4097) { pi.a("WifiDetectManager", (Object) ("onResult-CLOUND_CHECK:[" + message.arg1 + "]")); IWifiDetectListener iWifiDetectListener = (IWifiDetectListener) message.obj; if (iWifiDetectListener != null) { iWifiDetectListener.onResult(message.arg1); } } else if (i == 4098 && (iWifiBatchDetectListener = (IWifiBatchDetectListener) message.obj) != null) { iWifiBatchDetectListener.onResult(message.getData().getIntArray("RET")); } } } /* access modifiers changed from: package-private */ public class b implements t8 { /* renamed from: a reason: collision with root package name */ final /* synthetic */ IWifiDetectListener f1372a; b(IWifiDetectListener iWifiDetectListener) { this.f1372a = iWifiDetectListener; } @Override // tmsdkobf.t8 public void onFinish(int i, int i2, int i3, int i4, JceStruct jceStruct) { int i5; pi.a("WifiDetectManager", (Object) ("onFinish retCode:[" + i3 + "]dataRetCode:[" + i4 + "]")); pi.b("WifiDetectManager", "[WifiDetectManager] disconnect for detectDnsAndPhishing"); Message obtainMessage = jf.this.d.obtainMessage(4097); if (i3 != 0 || jceStruct == null || !(jceStruct instanceof h2)) { pi.a("WifiDetectManager", (Object) "[CLOUND_CHECK_NETWORK_ERROR]"); i5 = 16; } else { h2 h2Var = (h2) jceStruct; int i6 = h2Var.f1275b; if (i6 == 2) { pi.a("WifiDetectManager", (Object) "[CLOUND_CHECK_DNS_FAKE]ESafeType.EST_DnsException"); sf.c(1320068, "CLOUND_DNS_FAKE"); i5 = 18; } else if (i6 == 3) { pi.a("WifiDetectManager", (Object) "[CLOUND_CHECK_PHISHING_FAKE]ESafeType.EST_Phishing"); sf.c(1320068, "CLOUND_PHISHING_FAKE"); i5 = 19; } else if (i6 == 4) { pi.a("WifiDetectManager", (Object) "[CLOUND_CHECK_PASSWORD_LEAK_RISK]ESafeType.EST_PasswordLeak"); sf.c(1320068, "CLOUND_PASSWORD_LEAK_RISK"); i5 = 20; } else { pi.a("WifiDetectManager", (Object) ("[CLOUND_CHECK_NO_FAKE]safeType:[" + h2Var.f1275b + "]")); sf.c(1320068, "CLOUND_NO_FAKE"); i5 = 17; } } obtainMessage.arg1 = i5; obtainMessage.obj = this.f1372a; jf.this.d.sendMessage(obtainMessage); } } /* access modifiers changed from: package-private */ public class c implements Runnable { /* renamed from: b reason: collision with root package name */ final /* synthetic */ String f1374b; c(String str) { this.f1374b = str; } public void run() { yf a2 = zf.a(90); if (a2 != null && a2.f1826a) { jg.a(this.f1374b); } yf a3 = zf.a(33); if (a3 != null && a3.f1826a) { mg.b((mg.c) null); mg.d(); } jf.this.e.set(false); } } /* access modifiers changed from: package-private */ public class d implements t8 { /* renamed from: a reason: collision with root package name */ final /* synthetic */ int f1375a; /* renamed from: b reason: collision with root package name */ final /* synthetic */ e2 f1376b; final /* synthetic */ int[] c; final /* synthetic */ Message d; d(int i, e2 e2Var, int[] iArr, Message message) { this.f1375a = i; this.f1376b = e2Var; this.c = iArr; this.d = message; } @Override // tmsdkobf.t8 public void onFinish(int i, int i2, int i3, int i4, JceStruct jceStruct) { pi.a("WifiDetectManager", (Object) ("onFinish Cmd_CSBatchGetCloudCheck retCode:[" + i3 + "]dataRetCode:[" + i4 + "]")); pi.b("WifiDetectManager", "[WifiDetectManager] disconnect for detectPhishingBatch"); boolean z = true; if (i3 == 0 && jceStruct != null && (jceStruct instanceof g2)) { g2 g2Var = (g2) jceStruct; ArrayList<Integer> arrayList = g2Var.f1243b; if (arrayList == null || arrayList.size() != this.f1375a) { z = false; } else { for (int i5 = 0; i5 < this.f1375a; i5++) { pi.c("WifiDetectManager", (Object) ("[" + this.f1376b.f1199b.get(i5).f1301b + "][" + g2Var.f1243b.get(i5).intValue() + "]")); if (g2Var.f1243b.get(i5).intValue() == 3) { this.c[i5] = 19; } else if (g2Var.f1243b.get(i5).intValue() == 4) { this.c[i5] = 20; } else { this.c[i5] = 17; } } } } if (z) { Bundle bundle = new Bundle(); bundle.putIntArray("RET", this.c); this.d.setData(bundle); } jf.this.d.sendMessage(this.d); } } /* JADX WARNING: Missing exception handler attribute for start block: B:10:0x001e */ private String a(InputStream inputStream) { BufferedReader bufferedReader; StringBuilder sb; bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); sb = new StringBuilder(); while (true) { try { String readLine = bufferedReader.readLine(); if (readLine != null) { sb.append(readLine); } } catch (IOException unknown) { bufferedReader.close(); return sb.toString(); } catch (Throwable th) { try { bufferedReader.close(); } catch (IOException unused) { } throw th; } try { bufferedReader.close(); } catch (IOException unused2) { } return sb.toString(); } } /* JADX WARNING: Code restructure failed: missing block: B:23:0x00c3, code lost: if (r4 != null) goto L_0x00c9; */ /* JADX WARNING: Code restructure failed: missing block: B:26:0x00c7, code lost: if (0 != 0) goto L_0x00c9; */ /* JADX WARNING: Code restructure failed: missing block: B:29:?, code lost: r4.close(); */ private String a(String str, HttpURLConnection httpURLConnection) { String str2; InputStream inputStream = null; try { String host = new URL(str).getHost(); String host2 = httpURLConnection.getURL().getHost(); pi.a("WifiDetectManager", (Object) ("urlHost:[" + host + "]httpHost:[" + host2 + "]")); str2 = !host.equals(host2) ? httpURLConnection.getURL().toExternalForm() : null; if (str2 == null) { try { if (httpURLConnection.getHeaderField("Location") != null) { str2 = httpURLConnection.getHeaderField("Location"); pi.a("WifiDetectManager", (Object) ("111location:[" + str2 + "]")); } } catch (Throwable unused) { } } if (str2 == null && httpURLConnection.getHeaderField("Refresh") != null) { String[] split = httpURLConnection.getHeaderField("Refresh").split(";"); if (split.length == 2) { str2 = split[1].trim(); } pi.a("WifiDetectManager", (Object) ("222location:[" + str2 + "]")); } if (str2 == null) { inputStream = httpURLConnection.getInputStream(); if (inputStream != null) { str2 = b(inputStream); } pi.a("WifiDetectManager", (Object) ("333location:[" + str2 + "]")); } } catch (Throwable unused2) { str2 = null; } return str2; } private String b(InputStream inputStream) { String a2 = a(inputStream); pi.a("WifiDetectManager", (Object) ("parsePage-pageContent:[" + a2 + "]")); String[] strArr = {"http-equiv\\s*=\\s*[\"']*refresh[\"']*\\s*content\\s*=\\s*[\"']*[^;]*;\\s*url\\s*=\\s*[\"']*([^\"'\\s>]+)", "[^\\w](?:location.href\\s*=|location\\s*=|location.replace\\s*\\()\\s*[\"']*([^\"'>]+)", "<NextURL>([^<]+)", "\\s+action\\s*=\\s*[\"']*([^\"'>]+)[\"'>\\s]*.*submit", "<LoginURL>([^<]+)"}; int length = strArr.length; String str = null; for (int i = 0; i < length && str == null; i++) { Matcher matcher = Pattern.compile(strArr[i], 2).matcher(a2); while (matcher.find() && str == null) { str = matcher.group(matcher.groupCount()); if (str != null && !str.trim().toLowerCase().startsWith("http")) { str = null; } } } pi.a("WifiDetectManager", (Object) ("parsePage-location:[" + str + "]")); return str; } public synchronized int detectARPNoRoot(long j) { int i; pi.a("WifiDetectManager", (Object) "[Beg]detectARPNoRoot"); sf.f(29978); i = 261; try { i = new kf().a(this.c.getConnectionInfo().getBSSID(), j); } catch (Throwable th) { pi.a("WifiDetectManager", (Object) ("no root detect error:[" + th + "]")); } sf.c(1320068, i == 262 ? "NOROOT_ARP_FAKE" : "NOROOT_ARP_OK"); pi.a("WifiDetectManager", (Object) ("[End]detectARPNoRoot-nRetState:[" + i + "]")); return i; } /* JADX WARNING: Removed duplicated region for block: B:30:0x011c */ public int detectDnsAndPhishing(IWifiDetectListener iWifiDetectListener, long j) { String str; sf.f(29979); if (si.b(this.f1371b)) { pi.a("WifiDetectManager", (Object) ("[Beg]detectDnsAndPhishinglistener:[" + iWifiDetectListener + "]")); WifiInfo connectionInfo = ((WifiManager) this.f1371b.getSystemService("wifi")).getConnectionInfo(); if (connectionInfo == null) { return -2; } String ssid = connectionInfo.getSSID(); String bssid = connectionInfo.getBSSID(); pi.a("WifiDetectManager", (Object) ("ssid:[" + ssid + "]bssid:[" + bssid + "]")); if (yi.b(ssid) || yi.b(bssid)) { pi.a("WifiDetectManager", (Object) "[End]detectDnsAndPhishing 参数不对"); return -3; } String str2 = null; try { DhcpInfo dhcpInfo = this.c.getDhcpInfo(); if (dhcpInfo != null) { str = aj.a((long) dhcpInfo.dns1); try { str2 = aj.a((long) dhcpInfo.dns2); } catch (Exception unused) { } pi.a("WifiDetectManager", (Object) ("dns1:[" + str + "]dns2:[" + str2 + "]")); f2 f2Var = new f2(); f2Var.f1215b = new i2(); i2 i2Var = f2Var.f1215b; i2Var.f1301b = ssid; i2Var.c = bssid; f2Var.c = new ArrayList<>(); if (str != null && str.length() > 0) { f2Var.c.add(str); } if (str2 != null && str2.length() > 0) { f2Var.c.add(str2); } ya h = aa.h(); pi.a("WifiDetectManager", (Object) ("[GUID] " + h.a())); pi.a("WifiDetectManager", "[WifiDetectManager] connect for detectDnsAndPhishing"); h.a(794, f2Var, new h2(), 0, new b(iWifiDetectListener), j); qf.d(); if (!this.e.get()) { this.e.set(true); aa.i().a(new c(bssid), "w"); } pi.a("WifiDetectManager", (Object) ("[End]detectDnsAndPhishing-ssid:[" + ssid + "]bssid:[" + bssid + "]")); return 0; } } catch (Exception unused2) { } str = null; pi.a("WifiDetectManager", (Object) ("dns1:[" + str + "]dns2:[" + str2 + "]")); f2 f2Var2 = new f2(); f2Var2.f1215b = new i2(); i2 i2Var2 = f2Var2.f1215b; i2Var2.f1301b = ssid; i2Var2.c = bssid; f2Var2.c = new ArrayList<>(); f2Var2.c.add(str); f2Var2.c.add(str2); ya h2 = aa.h(); pi.a("WifiDetectManager", (Object) ("[GUID] " + h2.a())); pi.a("WifiDetectManager", "[WifiDetectManager] connect for detectDnsAndPhishing"); h2.a(794, f2Var2, new h2(), 0, new b(iWifiDetectListener), j); qf.d(); if (!this.e.get()) { } pi.a("WifiDetectManager", (Object) ("[End]detectDnsAndPhishing-ssid:[" + ssid + "]bssid:[" + bssid + "]")); return 0; } pi.a("WifiDetectManager", (Object) "[WifiConnected false]"); iWifiDetectListener.onResult(-1); return -1; } /* JADX WARNING: Code restructure failed: missing block: B:24:0x00bb, code lost: if (r9 != null) goto L_0x00db; */ /* JADX WARNING: Code restructure failed: missing block: B:32:0x00de, code lost: tmsdkobf.pi.a("WifiDetectManager", (java.lang.Object) ("[End]detectNetworkState-nRet:[" + r5 + "]")); */ /* JADX WARNING: Code restructure failed: missing block: B:33:0x00f5, code lost: return r5; */ public int detectNetworkState() { HttpURLConnection httpURLConnection; Object th; int i; sf.f(29981); pi.a("WifiDetectManager", (Object) "[Beg]detectNetworkState-urlApprove:[http://tools.3g.qq.com/wifi/cw.html]customHeader:[Meri]"); int i2 = 2; try { long currentTimeMillis = System.currentTimeMillis(); pi.a("WifiDetectManager", (Object) "openConnection"); httpURLConnection = (HttpURLConnection) new URL("http://tools.3g.qq.com/wifi/cw.html").openConnection(); try { if (wi.a() < 8) { System.setProperty("http.keepAlive", "false"); } httpURLConnection.setUseCaches(false); httpURLConnection.setRequestProperty("Pragma", "no-cache"); httpURLConnection.setRequestProperty("Cache-Control", "no-cache"); httpURLConnection.setInstanceFollowRedirects(false); httpURLConnection.setRequestMethod(NetworkApiHelper.REQUEST_METHOD_GET); httpURLConnection.setReadTimeout(30000); int responseCode = httpURLConnection.getResponseCode(); pi.a("WifiDetectManager", (Object) ("getResponseCode:[" + responseCode + "]timeMillis:[" + (System.currentTimeMillis() - currentTimeMillis) + "]")); if (responseCode == 200 || (responseCode >= 301 && responseCode <= 305)) { String headerField = httpURLConnection.getHeaderField("Meri"); pi.a("WifiDetectManager", (Object) ("customHeader: " + headerField)); if (headerField == null || headerField.compareToIgnoreCase("Meri") != 0) { String a2 = a("http://tools.3g.qq.com/wifi/cw.html", httpURLConnection); if (!(a2 == null || a2.compareToIgnoreCase("http://miwifi.com/diagnosis/index.html") == 0)) { i = 3; } } else { i = 1; } i2 = i; } } catch (Throwable th2) { th = th2; try { pi.a("WifiDetectManager", (Object) ("Throwable:[" + th + "]")); } finally { if (httpURLConnection != null) { httpURLConnection.disconnect(); } } } } catch (Throwable th3) { th = th3; httpURLConnection = null; pi.a("WifiDetectManager", (Object) ("Throwable:[" + th + "]")); } } public int detectPhishingBatch(List<String> list, List<String> list2, IWifiBatchDetectListener iWifiBatchDetectListener, long j) { sf.f(29979); Message obtainMessage = this.d.obtainMessage(ITrafficCorrectionListener.VERIFY_PHONE_NOT_SUPPORT); obtainMessage.obj = iWifiBatchDetectListener; if (si.i()) { pi.a("WifiDetectManager", (Object) ("detectPhishingBatchlistener:[" + iWifiBatchDetectListener + "]")); e2 e2Var = new e2(); e2Var.f1199b = new ArrayList<>(); int size = list.size(); int[] iArr = new int[size]; for (int i = 0; i < size; i++) { i2 i2Var = new i2(); i2Var.f1301b = list.get(i); i2Var.c = list2.get(i); e2Var.f1199b.add(i2Var); iArr[i] = 16; } e2Var.e = ui.h(); e2Var.f = ui.d(); e2Var.g = ui.g(); e2Var.h = ui.b(); e2Var.i = ui.j(); ya h = aa.h(); pi.c("WifiDetectManager", (Object) ("[GUID] " + h.a())); pi.a("WifiDetectManager", "[WifiDetectManager] connect for detectPhishingBatch"); h.a(800, e2Var, new g2(), 0, new d(size, e2Var, iArr, obtainMessage), j); return 0; } pi.a("WifiDetectManager", (Object) "[isNetworkConnected false]"); this.d.sendMessage(obtainMessage); return -1; } /* JADX WARNING: Code restructure failed: missing block: B:18:0x0089, code lost: if (r7 != null) goto L_0x00ab; */ /* JADX WARNING: Code restructure failed: missing block: B:26:0x00ae, code lost: tmsdkobf.pi.a("WifiDetectManager", (java.lang.Object) ("[End]detectSSLStrip-nRetState:[" + r6 + "]time(millis) elapsed:[" + (java.lang.System.currentTimeMillis() - r2) + "]")); */ /* JADX WARNING: Code restructure failed: missing block: B:27:0x00d5, code lost: if (r6 != 272) goto L_0x00da; */ /* JADX WARNING: Code restructure failed: missing block: B:28:0x00d7, code lost: r1 = "SSLSTRIP_ATTACK"; */ /* JADX WARNING: Code restructure failed: missing block: B:29:0x00da, code lost: r1 = "SSLSTRIP_OK"; */ /* JADX WARNING: Code restructure failed: missing block: B:30:0x00dc, code lost: tmsdkobf.sf.c(1320068, r1); */ /* JADX WARNING: Code restructure failed: missing block: B:31:0x00df, code lost: return r6; */ public int detectSSLStrip() { HttpURLConnection httpURLConnection; Object th; pi.a("WifiDetectManager", (Object) "[Beg]detectSSLStrip"); sf.f(1320084); long currentTimeMillis = System.currentTimeMillis(); if (!si.b(this.f1371b)) { pi.a("WifiDetectManager", (Object) "[End]detectSSLStrip-SSLSTRIP_WIFI_NOTAVILABLE"); return WifiDetectManager.SSLSTRIP_WIFI_NOTAVILABLE; } int i = WifiDetectManager.SSLSTRIP_OK; try { httpURLConnection = (HttpURLConnection) new URL("http://tools.3g.qq.com/j/sslstrip").openConnection(); try { httpURLConnection.setConnectTimeout(com.xiaomi.onetrack.g.b.f867a); httpURLConnection.setReadTimeout(com.xiaomi.onetrack.g.b.f867a); httpURLConnection.setInstanceFollowRedirects(false); int responseCode = httpURLConnection.getResponseCode(); List<String> list = httpURLConnection.getHeaderFields().get("Location"); if (list.size() == 1) { String lowerCase = list.get(0).toLowerCase(); pi.c("WifiDetectManager", (Object) ("url: " + lowerCase)); if (lowerCase.startsWith("http://m.qq.com")) { } } else if (responseCode == 200) { pi.c("WifiDetectManager", (Object) "StatusCode 200"); } i = 272; } catch (Throwable th2) { th = th2; try { pi.b("WifiDetectManager", (Object) ("t:[" + th + "]")); } finally { if (httpURLConnection != null) { httpURLConnection.disconnect(); } } } } catch (Throwable th3) { httpURLConnection = null; th = th3; pi.b("WifiDetectManager", (Object) ("t:[" + th + "]")); } } public int detectSecurity(ScanResult scanResult) { String str; sf.f(29980); pi.a("WifiDetectManager", (Object) ("[Beg]detectSecurity-AP:[" + scanResult + "]")); if (scanResult == null || (str = scanResult.capabilities) == null) { return -2; } int i = str.contains("WEP") ? 257 : scanResult.capabilities.contains("PSK") ? 258 : scanResult.capabilities.contains("EAP") ? 259 : scanResult.capabilities.contains("SAE") ? 260 : 256; pi.a("WifiDetectManager", (Object) ("[End]detectSecurity-Ret:[" + i + "]")); return i; } @Override // tmsdkobf.q9 public int getSingletonType() { return 2; } @Override // tmsdkobf.q9 public void onCreate(Context context) { pi.a("WifiDetectManager", (Object) ("OnCreate-context:[" + context + "]")); this.f1371b = context; this.c = (WifiManager) context.getSystemService("wifi"); this.d = new a(this, Looper.getMainLooper()); } }